NP-790: Fix bundle not working in Github action#3
Merged
illiaizotov-dev merged 2 commits intomasterfrom Apr 23, 2026
Merged
Conversation
Runtime and CI: - action.yml now uses runs.using: node24 (was node16) - Add .nvmrc pinning Node 24 and engines.node >= 24.0.0 in package.json - Project is native ESM: package.json "type": "module", tsconfig.json module/moduleResolution: NodeNext, so every relative import in src/**/*.ts and tests/**/*.ts carries a .js extension per spec - Compiled lib/*.js is native ESM; GitHub's node24 runtime loads it directly via Node's own ESM loader - Add a project-level .npmrc pinning registry=https://registry.npmjs.org/ so CI does not inherit a developer's private-registry config - .github/workflows/test.yml bumps actions/checkout and actions/setup-node to v6 and runs lint + check + test + build Dependency upgrades (aggressive majors, zero known vulnerabilities): - @actions/core 1.x -> 3.0.1 (pure ESM) - @actions/exec 1.x -> 3.0.0 (pure ESM) - @actions/github 4.x -> 9.1.1 (fixes the broken @octokit/core/dist-types/types deep import from 8.0.1 + reaches @octokit/core@7, plugin-paginate-rest@14, plugin-rest-endpoint-methods@17, request@10, request-error@7, undici@6) - @semantic-release/commit-analyzer 8 -> 13 (pure ESM) - @semantic-release/release-notes-generator 9 -> 14 (pure ESM) - conventional-changelog-conventionalcommits 4 -> 9 (pure ESM) - typescript 4.4 -> 5.9, @types/node 16 -> 24, prettier 2 -> 3 - New: eslint 9 (flat config), typescript-eslint 8 (strict + stylistic), @eslint/js, globals Source changes: - src/github.ts: migrated to octokit.rest.{repos,git}.* - Deleted src/ts.ts; replaced the custom Await<T> helper with the built-in TypeScript Awaited<T> - src/action.ts: added VALID_RELEASE_TYPES set + isReleaseType type guard replacing the prior `as ReleaseType` cast; release_type output is only set after inc() succeeds - src/main.ts: catch (error: unknown) with narrowing that surfaces error.stack and surfaces one level of error.cause (Error stack/message inline, non-Error causes JSON-stringified with a toString fallback) - src/utils.ts: dropped the @ts-ignore on default-release-types by inlining the constant list (the internal module is not a public export), added explicit MappedReleaseRule return type, refactored for noUncheckedIndexedAccess - types/semantic.d.ts: tightened `any` -> structural shapes Tooling: - tsconfig.json: target ES2023, strict + noUncheckedIndexedAccess + useUnknownInCatchVariables, module/moduleResolution NodeNext - tsconfig.eslint.json drives type-aware ESLint across src/**, tests/**, types/**, *.mjs, and vitest.config.ts - eslint.config.mjs (flat config) with strictTypeChecked + stylisticTypeChecked, plus a relaxed override for tests/**/*.ts that still enforces no-unused-vars with the ^_ escape hatch - Prettier 3 is happy across the tree; .prettierignore keeps LICENSE, .nvmrc, and binary assets out of the formatter Testing (Vitest 4): - Replaced Jest 30 + ts-jest + @types/jest + @jest/globals with vitest@^4.1.5 as the single dev dependency for the test stack; dropped jest.config.mjs, tsconfig.test.json, and the local tests/__mocks__/@semantic-release/* stubs entirely because Vitest loads the real ESM packages natively - Scripts: "test": "vitest run", "test:watch": "vitest" - New vitest.config.ts is ~20 lines: node environment, clearMocks + restoreMocks, 10s timeout, no globals - tests/github.test.ts: vi.mock('@actions/github', factory) hoisted above static imports; no more dynamic imports or awaited factories - tests/action.test.ts + tests/utils.test.ts: * vi.mock('@actions/core', async importOriginal => { ...actual, debug: vi.fn(), info: vi.fn(), setOutput: vi.fn(), setFailed: vi.fn() }) because Node seals the real ESM namespace and vi.spyOn cannot mutate it in place * vi.mock('../src/utils.js') and vi.mock('../src/github.js') with the same pattern; per-test behaviour goes through vi.mocked(utils.getCommits).mockImplementation(...) because ESM named imports are live bindings and spyOn on a namespace cannot redirect them * tests/action.test.ts installs the console.info suppression in beforeEach (restoreMocks: true restores any module-scope spy after the first test completes) - Built-in Node imports use the node: specifier (node:fs, node:path) Docs and metadata: - README.md "Usage" example points at the StackAdapt fork and the v7.0.0 tag that this commit is publishing - README.md "Developing locally" section documents the Vitest / ESLint / Prettier / tsc workflow - README.md `release_branches` and `previous_tag` / `previous_version` output descriptions now match the actual `src/action.ts` behaviour (skip-tag-creation path, synthetic `{tag_prefix}0.0.0` default) - action.yml inline descriptions for `release_branches`, `pre_release_branches`, and `previous_tag` brought into alignment with README + code; declares `previous_version` output explicitly - package.json `repository.url` now points at the StackAdapt fork Build output: - .gitignore no longer excludes lib/; the checked-in build is native ESM targeting Node 24 Validation: - 34/34 tests pass under Vitest (~0.6s) - npm run lint clean (ESLint strict + stylistic) - npm run check clean (Prettier 3) - npm run build clean (tsc -> native ESM in lib/) - npm audit: 0 vulnerabilities Made-with: Cursor
5a687a1 to
f4f79e7
Compare
Made-with: Cursor
f4f79e7 to
caa904d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Github uses only lib/ folder, meaning the whole bundle must be available in Git as node_modules are ignored